package org.example.threadlocaltest;

import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.annotation.MapperScans;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.security.config.annotation.authentication.configuration.EnableGlobalAuthentication;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.web.DefaultSecurityFilterChain;

import javax.servlet.Filter;

@SpringBootApplication
@MapperScan("org.example.threadlocaltest.demos.eneity.mapper")//mybatis-plus扫描mapper接口
@ServletComponentScan//扫描servlet druid监控页面需要加这个注解
@EnableGlobalMethodSecurity(prePostEnabled = true)//开启方法级别的权限控制
@EnableAsync    //开启异步
public class ThreadlocaltestApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(ThreadlocaltestApplication.class, args);
        System.out.printf("-------");
//        DefaultSecurityFilterChain bean = run.getBean(DefaultSecurityFilterChain.class);
//        System.out.println(" DefaultSecurityFilterChain   过滤器链------------------------------");
//        for (int i = 0; i < bean.getFilters().size(); i++) {
//            Filter filter = bean.getFilters().get(i);
//            System.out.println(i + "  -->  " + filter.getClass().getName());
//        }
        System.out.printf("启动成功");//在此处打断点，然后执行 run.getBean(DefaultSecurityFilterChain.class) 即可看到security默认带来的过滤器
        //但是一旦 使用了 BCryptPasswordEncoder 对密码进行加密
    }

}
